﻿@using Webdiyer.WebControls.Mvc;
@model PagedList<ChuangDu_Spirit_QGB_Model.PschanceInfo>

@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>项目销售机会</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="~/BootstrapSouce/css/bootstrap.css" rel="stylesheet" />
    <script src="~/BootstrapSouce/js/jquery.js"></script>
    <script src="~/BootstrapSouce/js/bootstrap.js"></script>
    <script src="~/Layui/layui-v2.2.3/layui/layui.all.js"></script>
    <script src="~/Layui/layui-v2.2.3/layui/layui.js"></script>
    <link href="~/Layui/layui-v2.2.3/layui/css/layui.mobile.css" rel="stylesheet" />
    <link href="~/Layui/layui-v2.2.3/layui/css/layui.css" rel="stylesheet" />
    <script src="~/layer/2.4/layer.js"></script>
    <script src="~/Scripts/jquery-1.10.2.js"></script>
    
    <script>
        //刷新
        function Refresh() {
            location.href = "PschanceShow";
        }


        //这是全选反选
        function xuan(obj) {
            if (obj.checked == true) {
                $("input[name='ck']:checkbox").each("checked", true);
            }
            else {

                $("input[name='ck']:checkbox").each(function () {
                    $(this).prop("checked", !$(this).prop("checked"));
                });
            }
        }
        //添加
        function Add() {

            var PschansName = $("#PschansName").val();
            var PschansTheme = $("#PschansTheme").val();
            var PschansType = $("#PschansType").val();
            var PschansLinkman = $("#PschansLinkman").val();
            var PschansFindTime = $("#PschansFindTime").val();
            var PschansSource = $("#PschansSource").val();
            var PschansPrincipal = $("#PschansPrincipal").val();
            var PschansPrincipal1 = $("#PschansPrincipal1").val();
            var PschansNeed = $("#PschansNeed").val();
            var PschansSignTime = $("#PschansSignTime").val();
            var PschansSignMoney = $("#PschansSignMoney").val();
            var PschansArea = $("#PschansArea").val();
            var PschansFremark = $("#PschansFremark").val();
            var PschansStage = $("#PschansStage").val();
            var PschansPoss = $("#PschansPoss").val();
            var PschansState = $("#PschansState").val();
            var PschansStageRemark = $("#PschansStageRemark").val();
            var PschansAccessory = $("#PschansAccessory").val();

            var flag2 = false;
            var PschansName1 = /^[\u4e00-\u9fa5]+$/;
            var PschansThememsg = /^[\u4e00-\u9fa5]+$/;
            if (!PschansName1.test(PschansName)) {
                $('#PschansNamemsg').text('客户名称为汉字，最大长度不超过十个字！');
                flag2 = false;
                return;
            }
            else {
                $('#PschansNamemsg').empty();
                flag2 = true;
            }
            if (!PschansThememsg.test(PschansTheme)) {
                $('#PschansThememsg').text('机会主题为汉字，最大长度不超过十个字！');
                flag2 = false;
                return;
            }
            else {
                $('#PschansThememsg').empty();
                flag2 = true;
            }
            if (flag2 == true) {
                $.ajax({
                    url: "/Pschance/PschanceAdd",
                    type: "post",
                    data: {
                        PschansName: PschansName,
                        PschansTheme: PschansTheme,
                        PschansType: PschansType,
                        PschansLinkman: PschansLinkman,
                        PschansFindTime: PschansFindTime,
                        PschansSource: PschansSource,
                        PschansPrincipal: PschansPrincipal,
                        PschansPrincipal1: PschansPrincipal1,
                        PschansNeed: PschansNeed,
                        PschansSignTime: PschansSignTime,
                        PschansSignMoney: PschansSignMoney,
                        PschansArea: PschansArea,
                        PschansFremark: PschansFremark,
                        PschansStage: PschansStage,
                        PschansPoss: PschansPoss,
                        PschansState: PschansState,
                        PschansStageRemark: PschansStageRemark,
                        PschansAccessory: PschansAccessory
                    },
                    success: function (data) {
                        if (data == 1) {
                            layer.msg("添加成功", {
                                icon: 1
                            });
                        }
                        else {
                            layer.msg("添加失败", {
                                icon: 2
                            });
                        }
                    }
                })
            }
            else
            {
                layer.msg("添加失败", {
                    icon: 2
                });
            }
               
        }

        //修改
        function Upt() {
      
            $("input[name='ck']:checkbox:checked").each(function () {
                ids.push(this.value);
            })
            var PschansName = $("#PschansName1").val();
            var PschansTheme = $("#PschansTheme1").val();
            var PschansType = $("#PschansType1").val();
            var PschansLinkman = $("#PschansLinkman1").val();
            var PschansFindTime = $("#PschansFindTime1").val();
            var PschansSource = $("#PschansSource1").val();
            var PschansPrincipal = $("#PschansPrincipal1").val();
            var PschansPrincipal1 = $("#PschansPrincipal11").val();
            var PschansNeed = $("#PschansNeed1").val();
            var PschansSignTime = $("#PschansSignTime1").val();
            var PschansSignMoney = $("#PschansSignMoney1").val();
            var PschansArea = $("#PschansArea1").val();
            var PschansFremark = $("#PschansFremark1").val();
            var PschansStage = $("#PschansStage1").val();
            var PschansPoss = $("#PschansPoss1").val();
            var PschansState = $("#PschansState1").val();
            var PschansStageRemark = $("#PschansStageRemark1").val();
            var PschansAccessory = $("#PschansAccessory1").val();

            var flag2 = false;
            var PschansName1 = /^[\u4e00-\u9fa5]+$/;
            var PschansThememsg = /^[\u4e00-\u9fa5]+$/;
            if (!PschansName1.test(PschansName)) {
                $('#PschansNamemsg1').text('客户名称为汉字，最大长度不超过十个字！');
                flag2 = false;
                return;
            }
            else {
                $('#PschansNamemsg1').empty();
                flag2 = true;
            }
           
            if (flag2 == true) {
                $.ajax({
                    url: "/Pschance/PschanceEdit",
                    type: "post",
                    data: {
                        PschansName: PschansName,
                        PschansTheme: PschansTheme,
                        PschansType: PschansType,
                        PschansLinkman: PschansLinkman,
                        PschansFindTime: PschansFindTime,
                        PschansSource: PschansSource,
                        PschansPrincipal: PschansPrincipal,
                        PschansPrincipal1: PschansPrincipal1,
                        PschansNeed: PschansNeed,
                        PschansSignTime: PschansSignTime,
                        PschansSignMoney: PschansSignMoney,
                        PschansArea: PschansArea,
                        PschansFremark: PschansFremark,
                        PschansStage: PschansStage,
                        PschansPoss: PschansPoss,
                        PschansState: PschansState,
                        PschansStageRemark: PschansStageRemark,
                        PschansAccessory: PschansAccessory
                    },
                    success: function (data) {
                        if (data == 1) {
                            layer.msg("修改成功", {
                                icon: 1
                            });
                        }
                        else {
                            layer.msg("修改失败", {
                                icon: 2
                            });
                        }
                    }
                })
            }
            else {
                layer.msg("修改失败", {
                    icon: 2
                });
            }

        }


        //批量删除
        function Pidel() {
            var ids = [];
            $("input[name='ck']:checkbox:checked").each(function () {
                ids.push(this.value);
            })
            layer.confirm("你确定删除么？",
                { btn: ['我确定', '不想'] },
                    function (obj) {
                        $.ajax({
                            url: "/Pschance/PschanceDetails",
                            type: "post",
                            data: { ids: ids.toString() },
                            success: function (data) {
                                if (data == 1) {

                                    $("input[name='ck']:checkbox:checked").each(function () {
                                        $(this).parent().parent().remove();
                                    })
                                    layer.msg("删除成功！");
                                }
                                else
                                    layer.msg("未选中，删除失败！");
                            }
                        })
                    }

                )

        }
    </script>
    <style>
        label{
            font-size:12px;
            color:red;
            font-family:隶书;
        }
    </style>
</head>
<body style="padding-left:30px;padding-right:30px;">
    <div style="width:100%;height:50px;margin:0 auto">
        <div class="layui-btn-group" style="float:left;padding-top:20px;">
            <button class="layui-btn layui-btn-primary" onclick="xuan(this)"><i class="layui-icon">&#xe627;</i>全选</button>
            <button class="layui-btn layui-btn-primary" onclick="Refresh()"><i class="layui-icon">&#x1002;</i>刷新</button>
            <a href="#Add" data-toggle="modal">
                <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe608;</i>新建合同/订单</button>
            </a>
            <a href="#Add" data-toggle="modal">
                <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe642;</i>编辑</button>
            </a>
            <button class="layui-btn layui-btn-primary" onclick="Pidel()"> <i class="layui-icon">&#xe640;</i>删除</button>
            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe67c;</i>导入EXCEL</button>
            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe609;</i>导出本页</button>
            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe62d;</i>导出全部</button>
            
        </div>
        <div class="demoTable" style="float:right;padding-right:20px;margin-top:20px;">
            <form method="get" action="PschanceShow">
                <div class="layui-inline">
                    <input class="layui-input" name="name" id="demoReload" autocomplete="off"> 
                </div>
                <button class="layui-btn" type="submit"><i class="layui-icon">&#xe615;</i></button>
                <button class="layui-btn"><i class="layui-icon">&#xe614;</i></button>
            </form>
            
            
        </div>
    </div>
    <div style="width:100%;height:400px;">
        <div style="width:98%;height:390px; overflow-y:scroll; overflow-x:scroll;">
            <table class="layui-table" style="text-align:center;width:120%;">

                <thead>
                    <tr style="background-color:#31b0d5;color:#ffffff">
                        <td lay-data="{type:'checkbox', fixed: 'left'}"><input id="Checkbox1" type="checkbox" /></td>
                        <td>客户名称</td>
                        <td>机会主题</td>
                        <td>类型</td>
                        <td>联系人</td>
                        <td>发现时间 </td>
                        <td>来源 </td>
                        <td>负责人</td>
                        <td>提供人</td>
                        <td>客户需求 </td>
                        <td>预计签单日期 </td>
                        <td>预计金额</td>
                        <td>区域</td>
                        <td>外币备注</td>
                        <td>阶段</td>
                        <td>可能性</td>
                        <td>状态</td>
                        <td>阶段备注</td>
                        <td>附件</td>
                    </tr>
                </thead>
                @foreach (var x in Model)
                {
                    <tr>
                        <td lay-data="{type:'checkbox'}"><input id="@x.Id" type="checkbox" name="ck" value="@x.Id" /></td>
                        <td>@x.PschansName</td>
                        <td>@x.PschansTheme</td>
                        <td>@x.PschansType</td>
                        <td>@x.PschansLinkman</td>
                        <td>@x.PschansFindTime</td>
                        <td>@x.PschansSource</td>
                        <td>@x.PschansPrincipal</td>
                        <td>@x.PschansPrincipal1</td>
                        <td>@x.PschansNeed</td>
                        <td>@x.PschansSignTime</td>
                        <td>@x.PschansSignMoney</td>
                        <td>@x.PschansArea</td>
                        <td>@x.PschansFremark</td>
                        <td>@x.PschansStage</td>
                        <td>@x.PschansPoss</td>
                        <td>@x.PschansState</td>
                        <td>@x.PschansStageRemark</td>
                        <td>@x.PschansAccessory</td>
                    </tr>
                }

            </table>
        </div>
    </div>
    
    <div style="padding-left:50px;margin-top:50px;">

        <span style="font-size:16px;color:red"> @Model.CurrentPageIndex/ @Model.TotalPageCount</span> <span style="font-size:16px;color:red">
            总共 @Model.TotalItemCount 条记录
        </span>


        <div class="text-left">
            @Html.Pager(Model, new PagerOptions { PageIndexParameterName = "id", ContainerTagName = "ul", CssClass = "pagination", CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>", DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>", PagerItemTemplate = "<li>{0}</li>", Id = "bootstrappager", FirstPageText = "第一页", LastPageText = "最后一页", PrevPageText = "上一页", NextPageText = "下一页" })
        </div>
    </div>

    <fieldset class="layui-elem-field layui-field-title" style="margin-top:30px;"></fieldset>


    @*添加模态*@
    <div class="modal fade" id="Add" aria-hidden="true" style="height:500px;margin-top:50px;">
        <div class="modal-dialog">
            <div class="modal-content">
                @using (Html.BeginForm("PschanceAdd", "Pschance", FormMethod.Post))
                {
                    <div class="modal-header" style="background-color:#0094ff">
                        <h3>新增项目销售</h3>
                    </div>
                    <div class="modal-body">
                        <table class="table">
                            <tr>
                                <td>客户姓名</td>
                                <td><input type="text" id="PschansName" class="form-control" /></td>
                                <td colspan="2"><label id="PschansNamemsg"></label></td>
                            </tr>
                            <tr>
                                <td>机会主题</td>
                                <td><input type="text" id="PschansTheme" class="form-control" /></td>
                                <td colspan="2"><label id="PschansThememsg"></label></td>
                            </tr>
                            <tr>
                                <td>类型</td>
                                <td>
                                    @Html.DropDownList("PschanceName", null, new { @class = "form-control", id = "PschansType" })
                                </td>
                                <td>联系人</td>
                                <td><input type="text" id="PschansLinkman" class="form-control" /></td>
                            </tr>
                            <tr>
                                <td>发现时间</td>
                                <td><input type="date" id="PschansFindTime" class="form-control" /></td>
                                <td>来源</td>
                                <td><input type="text" id="PschansSource" class="form-control" /></td>
                            </tr>
                            <tr>
                                <td>负责人</td>
                                <td><input type="text" id="PschansPrincipal" class="form-control" /></td>
                                <td>提供人</td>
                                <td><input type="text" id="PschansPrincipal1" class="form-control" /></td>
                            </tr>
                            <tr>
                                <td>客户需求</td>
                                <td><input type="text" id="PschansNeed" class="form-control" /></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>预计签单日期</td>
                                <td><input type="date" id="PschansSignTime" class="form-control" /></td>
                                <td>预计金额</td>
                                <td><input type="number" id="PschansSignMoney" class="form-control" /></td>
                            </tr>
                            <tr>
                                <td>区域</td>
                                <td><input type="text" id="PschansArea" class="form-control" /></td>
                                <td>外币备注</td>
                                <td><input type="text" id="PschansFremark" class="form-control" /></td>
                            </tr>
                            <tr>
                                <td>阶段</td>
                                <td><input type="text" id="PschansStage" class="form-control" /></td>
                                <td>可能性</td>
                                <td><input type="text" id="PschansPoss" class="form-control" /></td>
                            </tr>
                            <tr>
                                <td>状态</td>
                                <td><input type="text" id="PschansState" class="form-control" /></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>阶段备注</td>
                                <td><input type="text" id="PschansStageRemark" class="form-control" /></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>+附件</td>
                                <td><input type="file" id="PschansAccessory" class="form-control" /></td>
                                <td></td>
                            </tr>
                        </table>


                    </div>
                    <div class="modal-footer" style="background-color:#0094ff">
                        <input type="button" data-dismiss="modal" value="返回" class="col-lg-3 col-lg-pull-0" />
                        <input type="button" value="新增" class="col-lg-3 col-lg-push-5 btn btn-success" onclick="Add()" /><br />
                    </div>

                }
            </div>


        </div>
    </div>

    @*修改数据*@
    @*<div class="modal fade" id="Upt" aria-hidden="true" style="height:500px;margin-top:50px;">
        <div class="modal-dialog">
            <div class="modal-content">
                    <div class="modal-header" style="background-color:#0094ff">
                        <h3>新增项目销售</h3>
                    </div>
                    <div class="modal-body">
                        <table class="table">
                            <tr>
                                <td>客户姓名 <input type="text" hidden="hidden" value="@ViewBag.PschanceUpt.Id" /></td>
                                <td><input type="text" id="PschansName1" class="form-control" value="@ViewBag.PschanceUpt.PschansName" /></td>
                                <td colspan="2"><label id="PschansNamemsg1"></label></td>
                            </tr>
                            <tr>
                                <td>机会主题</td>
                                <td><input type="text" id="PschansTheme1" class="form-control" value="@ViewBag.PschanceUpt.PschansTheme" /></td>
                                <td colspan="2"></td>
                            </tr>
                            <tr>
                                <td>类型</td>
                                <td>
                                    @Html.DropDownList("PschanceName", null, new { @class = "form-control", id = "PschansType" })
                                </td>
                                <td>联系人</td>
                                <td><input type="text" id="PschansLinkman1" class="form-control" value="@ViewBag.PschanceUpt.PschansLinkman" /></td>
                            </tr>
                            <tr>
                                <td>发现时间</td>
                                <td><input type="date" id="PschansFindTime1" class="form-control" @ViewBag.PschanceUpt.PschansFindTime /></td>
                                <td>来源</td>
                                <td><input type="text" id="PschansSource1" class="form-control" @ViewBag.PschanceUpt.PschansSource /></td>
                            </tr>
                            <tr>
                                <td>负责人</td>
                                <td><input type="text" id="PschansPrincipal1" class="form-control" @ViewBag.PschanceUpt.PschansPrincipal /></td>
                                <td>提供人</td>
                                <td><input type="text" id="PschansPrincipal11" class="form-control" @ViewBag.PschanceUpt.PschansPrincipal1 /></td>
                            </tr>
                            <tr>
                                <td>客户需求</td>
                                <td><input type="text" id="PschansNeed1" class="form-control" @ViewBag.PschanceUpt.PschansNeed /></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>预计签单日期</td>
                                <td><input type="date" id="PschansSignTime1" class="form-control" @ViewBag.PschanceUpt.PschansSignTime /></td>
                                <td>预计金额</td>
                                <td><input type="number" id="PschansSignMoney1" class="form-control" @ViewBag.PschanceUpt.PschansSignMoney /></td>
                            </tr>
                            <tr>
                                <td>区域</td>
                                <td><input type="text" id="PschansArea1" class="form-control" @ViewBag.PschanceUpt.PschansArea /></td>
                                <td>外币备注</td>
                                <td><input type="text" id="PschansFremark1" class="form-control" @ViewBag.PschanceUpt.PschansFremark /></td>
                            </tr>
                            <tr>
                                <td>阶段</td>
                                <td><input type="text" id="PschansStage1" class="form-control" @ViewBag.PschanceUpt.PschansStage /></td>
                                <td>可能性</td>
                                <td><input type="text" id="PschansPoss1" class="form-control" @ViewBag.PschanceUpt.PschansPoss /></td>
                            </tr>
                            <tr>
                                <td>状态</td>
                                <td><input type="text" id="PschansState1" class="form-control" @ViewBag.PschanceUpt.PschansState /></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>阶段备注</td>
                                <td><input type="text" id="PschansStageRemark1" class="form-control" @ViewBag.PschanceUpt.PschansStageRemark /></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>+附件</td>
                                <td><input type="file" id="PschansAccessory1" class="form-control" @ViewBag.PschanceUpt.PschansAccessory /></td>
                                <td></td>
                            </tr>
                        </table>


                    </div>
                    <div class="modal-footer" style="background-color:#0094ff">
                        <input type="button" data-dismiss="modal" value="返回" class="col-lg-3 col-lg-pull-0" />
                        <input type="button" value="修改" class="col-lg-3 col-lg-push-5 btn btn-success" onclick="Upt()" /><br />
                    </div>

                
            </div>


        </div>
    </div>*@
</body>
</html>

